









<div class="admin-biaogelist">

    <div class="listbiaoti am-cf">
        <ul class="am-icon-flag on"> 添加轮播图</ul>

        <dl class="am-icon-home" style="float: right;">当前位置： 首页 > <a href="#">添加轮播图</a></dl>

        <!--<dl>
          <button type="button" class="am-btn am-btn-danger am-round am-btn-xs am-icon-plus" > 补充线订单</button>
        </dl>-->
        <!--这里打开的是新页面-->

    </div>

    <div class="fbneirong">
        <form class="am-form jdtask">
            <div class="am-form-group am-cf">
                <div class="zuo">标题：</div>
                <div class="you">
                    <input type="text" class="am-input-sm"  name="title"  value="<?php echo$title; ?>" placeholder="请输入文章标题">
                </div>
            </div>
            <div class="am-form-group am-cf">
                <div class="zuo">链接：</div>
                <div class="you">
                    <input type="text" class="am-input-sm"  name="link" value="<?php echo$link; ?>"  maxlength="60" placeholder="不输入默认为本站文章">
                </div>
            </div>

            <div class="am-form-group am-cf">
                <div class="zuo">排序：</div>
                <div class="you">
                    <input type="number" class="am-input-sm"  name="order"  value="<?php echo$order; ?>"  maxlength="60" placeholder="请输入排序">
                </div>
            </div>
            <div class="am-form-group am-cf">
                <div class="zuo">图片：</div>
                <div class="you" style="height: 45px;">
                    <div  class="picbox" style="">
                        <img src="<?php echo base_url();?>/public/assets/image/wsc.png" class="picshow"   style="height: 45px" >
                    </div>

                        <input type="file" name="uploadFile" class="uploadPicButton" id="upload_file">

                </div>
            </div>

            <div class="am-form-group am-cf">
                <div class="you" style="margin-left: 11%; margin-top: 60px;">
                  <div    id="fabu" class="am-btn am-btn-secondary am-radius">发布</div>

                </div>
            </div>
        </form>



    </div>



    <script>
        var picurl="<?php echo$url; ?>";
        var id="<?php echo$id; ?>";

        if(picurl!=""){
            $(".picshow").addClass("newpic");
            $(".picshow").attr("src",picurl);
        }
        var picpath="";
        $(".uploadPicButton").change(function () {
            var pic = $('#upload_file')[0].files[0];
            var fd = new FormData();
            fd.append('upfile', pic);
            var url = "<?php echo base_url(); ?>/Customer/eidteruppic";

            $.ajax({
                url:url,
                type:"post",
                dataType:"json",
                // Form数据
                data: fd,
                cache: false,
                contentType: false,
                processData: false,
                success:function(data){
                    if(data.code==0){
                        $(".picshow").attr("src",data.url);
                        $(".picshow").addClass("newpic");
                        $(".picshow").show();
                        $("input[name=pic]").val(data.url);

                        picurl=data.url;
                        picpath=data.name;


                        return;
                    }
                    layer.msg(data.msg);
                }
            });
        });
    </script>
    <script>
        var picpath="";
        function uploadPic(){
            var pic = $('#upload_file')[0].files[0];
            var fd = new FormData();
            fd.append('uploadFile', pic);


            var url = "<?php echo base_url(); ?>/Customer/uppic";

            $.ajax({
                url:url,
                type:"post",
                dataType:"json",
                // Form数据
                data: fd,
                cache: false,
                contentType: false,
                processData: false,
                success:function(data){
                    if(data.code==0){
                        $(".picshow").attr("src",data.url)
                        $(".picshow").show();
                        $("input[name=pic]").val(data.url);
                        picurl=data.url;
                        picpath=data.name;
                        return;
                    }
                    layer.msg(data.msg);

                }

            });
        }
    </script>


    <script>



      $(function () {
          var on_request=false;
          $("#fabu").click(function () {
              fabu()
          });
          function fabu() {
              if (on_request) {
                  return;
              }              var url = "<?php echo base_url(); ?>/Customer/editepic";
              var postdata = {};

              var title=$("input[name=title]").val();
              var link=$("input[name=link]").val();
              var order=$("input[name=order]").val();


              postdata['id'] = id;
              postdata['title'] = title;
              postdata['link'] = link;
              postdata['order'] = order;

              var alldata=1;
              var valuekey='';
              $.each(postdata, function (key, value) {
                  if(value=="" && key!='order' ){
                      valuekey=key;
                      alldata=0;
                      return false;
                  }
              });
              if(!alldata){
                  alert("缺少参数");
                  $("input[name='"+valuekey+"']").focus();
                  on_request = false;
                  return;
              }
              postdata['url'] = picurl;
              on_request = true;
              $.post(url, postdata, function (data) {
                  on_request = false;
                  if(data.code==0){
                      layer.msg("图片编辑成功");
                      window.location.href="<?php echo base_url() ?>"+'/Customer/piclist' ;

                  } else{
                      alert(data.msg)
                  }
              },"json");
          }

      })
    </script>


    <div class="foods">
        <ul>
            版权所有@2015.
        </ul>
        <dl>
            <a href="" title="返回头部" class="am-icon-btn am-icon-arrow-up"></a>
        </dl>
    </div>




</div>











</body>
</html>